//
//  SelectionTyreCollectionViewCell.m
//  BigTyre
//
//  Created by 💋索少杰 on 2017/3/24.
//  Copyright © 2017年 Lemon. All rights reserved.
//

#import "SelectionTyreCollectionViewCell.h"
#import <SDAutoLayout.h>
#import <SDWebImage/UIImageView+WebCache.h>
@implementation SelectionTyreCollectionViewCell

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        _img=[[UIImageView alloc] init];
        _img.layer.cornerRadius=2;
        _img.layer.masksToBounds=YES;
        _img.backgroundColor=[UIColor redColor];
        [self.contentView addSubview:self.img];
        
        _name=[[UILabel alloc]init];
        _name.font=[UIFont systemFontOfSize:15];
        _name.textColor=[UIColor blackColor];
        [self.contentView addSubview:self.name];
        
        _renqi=[[UILabel alloc]init];
        _renqi.font=[UIFont systemFontOfSize:14];
        _renqi.textColor=[UIColor redColor];
        [self.contentView addSubview:self.renqi];
        
        _price=[[UILabel alloc]init];
        _price.font=[UIFont systemFontOfSize:18];
        _price.textColor=[UIColor redColor];
        [self.contentView addSubview:self.price];
        
        _price_yj=[[UILabel alloc]init];
        _price_yj.font=[UIFont systemFontOfSize:18];
        _price_yj.textColor=[UIColor grayColor];
        [self.contentView addSubview:self.price_yj];
        
        
        _img.sd_layout
        .leftSpaceToView(self.contentView,0)
        .topSpaceToView(self.contentView,0)
        .widthIs(135)
        .heightIs(120);
        
        _name.sd_layout
        .leftSpaceToView(self.contentView,0)
        .topSpaceToView(self.img,8)
        .widthIs(self.contentView.frame.size.width)
        .autoHeightRatio(0);
        
        _price.sd_layout
        .leftSpaceToView(self.img,10)
        .topSpaceToView(self.contentView,10)
        .widthIs(150)
        .autoHeightRatio(0);
        
        _price_yj.sd_layout
        .leftSpaceToView(self.img,10)
        .topSpaceToView(self.price,15)
        .widthIs(150)
        .autoHeightRatio(0);
        
        _renqi.sd_layout
        .leftSpaceToView(self.img,10)
        .topSpaceToView(self.price_yj,18)
        .widthIs(100)
        .autoHeightRatio(0);
        
        //[self setupAutoHeightWithBottomViewsArray:@[_img,_name,_price,_price_yj,_renqi] bottomMargin:10];
}
    
    return self;
}

- (void)setSModel:(SelectTyreCollectionModel_product *)sModel {
    
    [_img sd_setImageWithURL:[NSURL URLWithString:sModel.img] placeholderImage:[UIImage imageNamed:@""]];
    
    _name.text=sModel.name;
    _price.text=[NSString stringWithFormat:@"现价:￥%@",sModel.price];
    _price_yj.text=[NSString stringWithFormat:@"原价:￥%@",sModel.price_yj];
    _renqi.text=[NSString stringWithFormat:@"人气数:%@",sModel.renqi];
}


@end
